<?php
/**
 * Created by PhpStorm.
 * User: Sixstar-Peter
 * Date: 2019/4/16
 * Time: 21:41
 */

$chan = new chan(3);
//生产数据
go(function () use ($chan) {
    //查redis
    Co::sleep(2);
    $chan->push("token");
});

//消费数据
go(function () use ($chan) {
    //调用api需要token,token要从redis当中获得
    Co::sleep(3);
    var_dump($chan->pop()); //阻塞状态
});
